<?php echo $this->Session->flash(); ?>
<br>
<br>

<?php echo $ajax->link($html->image("regresar.gif", array('width' => '30', 'heigth' => '30', 'alt' => 'regresar', 'align' => 'center')), array('controller' => 'Candidates', "action" => "state"), array('escape' => false, 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading')); ?>



<table id="tabla" class="tabla"  >
    <thead>
        <tr>
            <th>Documento</th>
            <th>Nombre</th>
            <th>Requisito</th>
            <th>Calificación</th>
            <th>Subsanación</th>
            <th>Reclamación</th>

        </tr>
    </thead>
    <tbody>

        <?php
        foreach ($cabeza as $ben):

            switch ($ben['CandidateRequirement']['calificacion']) {
                case 0:
                    $tp = "Sin registro";
                    break;

                case 2:
                    $tp = "No cumple";
                    break;
                case 3:
                    $tp = "Subsanable";
                    break;


                default:
                    $tp = "";
                    break;
            }
            ?>

            <tr >
                <td><?php echo $ben['Candidate']['nro_ident']; ?></td>
                <td><?php echo $ben['Candidate']['1er_nombre'] . " " . $ben['Candidate']['1er_apellido'] ?></td>
                <td><?php echo $ben['Requirement']['texto'] ?></td>
                <td><?php echo $tp ?></td>
                <td>
                    <table>
                        <tr>
                            <td>Calificación:</td>
                            <td><?php
        $cr = "";
        switch ($ben['CandidateRequirement']['cal_subsanacion']) {
            case 0:
                $cr = "Sin registro";
                break;
            case 1:
                $cr = "Subsanó,cumple";
                break;
            case 2:
                $cr = "Subsanó,no cumple";
                break;
            case 2:
                $cr = "No Subsanó";
                break;

            default:
                break;
        }
        echo $cr;
            ?>
                            </td></tr>
                        <tr>
                            <td>Concepto:</td>
                            <td><?php echo $ben['CandidateRequirement']['con_subsanacion'] ?></td>
                        </tr>
                    </table>
                </td>

                <td>
                    <table>
                        <?php
                        App::Import('model', 'CandidateRequirementClaim');
                        $claim = new CandidateRequirementClaim();
                        $reclamaciones = $claim->find('all', array('conditions' => array('CandidateRequirementClaim.candidate_requirement_id' => $ben['CandidateRequirement']['id']), 'fields' => array('CandidateRequirementClaim.calificacion', 'CandidateRequirementClaim.concepto')));

                        foreach ($reclamaciones as $reclamaciones):
                            ?>
                            <tr>
                                <td>Calificación:</td>
                                <td><?php echo $reclamaciones['CandidateRequirementClaim']['calificacion'] ?></td>
                            </tr>
                            <tr>
                                <td>Concepto:</td>
                                <td><?php echo $reclamaciones['CandidateRequirementClaim']['concepto'] ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </table>
                </td>

            </tr>
        <?php endforeach; ?>

        <?php
        $cuenta = 0;
        $resp = "";
        App::Import('Model', 'Candidate');

        $can = new Candidate();
        $can->recursive = 0;
        $cuenta = $can->find('count', array('conditions' => array('Candidate.nro_ident' => $candidato['Candidate']['nro_ident'])));

        if ($cuenta > 1) {
            $asps = $can->find('all', array('conditions' => array('Candidate.nro_ident' => $candidato['Candidate']['nro_ident']), 'fields' => array('Proyect.codigo', 'Candidate.candidate_id')));


            foreach ($asps as $asp) {
                if ($asp['Candidate']['candidate_id'] != 0) {
                    $resp.="El Aspirante Se encuentra inscrito como conyuge en el proyecto " . $asp['Proyect']['codigo'] . "<br>";
                } else {
                    $resp.="El Aspirante Se encuentra inscrito como cabeza de familia  en el proyecto " . $asp['Proyect']['codigo'] . "<br>";
                }
            }
        }
        $cuenta1 = $can->Relative->find('count', array('conditions' => array('Relative.nro_ident' => $candidato['Candidate']['nro_ident'])));

        if ($cuenta1 > 0) {
            $can->Relative->recursive = -1;
            $relatives = $can->Relative->find('all', array('conditions' => array('Relative.nro_ident' => $candidato['Candidate']['nro_ident']), 'fields' => array('Relative.candidate_id')));
            foreach ($relatives as $rel) {
                $padre = $can->find('first', array('conditions' => array('Candidate.id' => $rel['Relative']['candidate_id']), 'fields' => array('Candidate.1er_nombre', 'Candidate.1er_apellido', 'Candidate.nro_ident', 'Proyect.codigo')));
                $resp.="El aspirante se encuentra como familiar de " . $padre['Candidate']['1er_nombre'] . " " . $padre['Candidate']['1er_apellido'] . ",Cedula: " . $padre['Candidate']['nro_ident'] . " ,en el proyecto: " . $padre['Proyect']['codigo'] . "<br>";
                //var_dump($padre);
            }
        }
        ?>



        <?php if ($resp <> ""): ?>

            <tr>
                <td style="color: #cb2c2c">DUPLICIDAD</td>
                <td colspan="3" style="color: #cb2c2c"><?php echo $resp ?></td>
                <td></td>
            </tr>
        <?php endif; ?>
    </tbody>
</table>
<br><br><br><h1>REQUISITOS DEL CONYUGE </h1>
<table id="tabla" class="tabla"   >
    <thead>
        <tr>
            <th>Documento</th>
            <th>Nombre</th>
            <th>Requisito</th>
            <th>Calificación</th>
            <th>Subsanación</th>
            <th>Reclamación</th>

        </tr>
    </thead>
    <tbody>

        <?php
        $resp = "";
        foreach ($conyuge as $ben):

            switch ($ben['CandidateRequirement']['calificacion']) {
                case 0:
                    $tp = "Sin registro";
                    break;

                case 2:
                    $tp = "No cumple";
                    break;
                case 3:
                    $tp = "Subsanable";
                    break;


                default:
                    $tp = "";
                    break;
            }
            ?>

            <tr >

                <td><?php echo $ben['Candidate']['nro_ident'] ?></td>
                <td><?php echo $ben['Candidate']['1er_nombre'] . " " . $ben['Candidate']['1er_apellido'] ?></td>

                <td><?php echo $ben['Requirement']['texto'] ?></td>
                <td><?php echo $tp ?></td>
                <td>
                    <table>
                        <tr>
                            <td>Calificación:</td>
                            <td><?php
        $cr = "";
        switch ($ben['CandidateRequirement']['cal_subsanacion']) {
            case 0:
                $cr = "Sin registro";
                break;
            case 1:
                $cr = "Subsanó,cumple";
                break;
            case 2:
                $cr = "Subsanó,no cumple";
                break;
            case 2:
                $cr = "No Subsanó";
                break;

            default:
                break;
        }
        echo $cr;
            ?>
                            </td></tr>
                        <tr>
                            <td>Concepto:</td>
                            <td><?php echo $ben['CandidateRequirement']['con_subsanacion'] ?></td>
                        </tr>
                    </table>
                </td>

                <td>
                    <table>

                        <?php
                        $claim = new CandidateRequirementClaim();
                        $reclamaciones = $claim->find('all', array('conditions' => array('CandidateRequirementClaim.candidate_requirement_id' => $ben['CandidateRequirement']['id']), 'fields' => array('CandidateRequirementClaim.calificacion', 'CandidateRequirementClaim.concepto')));

                        foreach ($reclamaciones as $reclamaciones):
                            ?>
                            <tr>
                                <td>Calificación:</td>
                                <td><?php echo $reclamaciones['CandidateRequirementClaim']['calificacion'] ?></td>
                            </tr>
                            <tr>
                                <td>Concepto:</td>
                                <td><?php echo $reclamaciones['CandidateRequirementClaim']['concepto'] ?></td>
                            </tr>
                        <?php endforeach; ?>

                    </table>
                </td>
            </tr>
        <?php endforeach; ?>

        <?php
        $resp = "";
        $can = new Candidate();
        $can->recursive = 0;

        if (!empty($pareja)) {

            $cuenta = $can->find('count', array('conditions' => array('Candidate.nro_ident' => $pareja['Candidate']['nro_ident'])));
            $cuenta1 = $can->Relative->find('count', array('conditions' => array('Relative.nro_ident' => $pareja['Candidate']['nro_ident'])));
            $pareja['Candidate']['nro_ident'] . "XXXX";
            if ($cuenta > 1) {
                $asps = $can->find('all', array('conditions' => array('Candidate.nro_ident' => $pareja['Candidate']['nro_ident']), 'fields' => array('Proyect.codigo', 'Candidate.candidate_id')));
                var_dump($asps);
                foreach ($asps as $asp) {
                    if ($asp['Candidate']['candidate_id'] != 0) {
                        $resp.="El Aspirante Se encuentra inscrito como conyuge en el proyecto " . $asp['Proyect']['codigo'] . "<br>";
                    } else {
                        $resp.="El Aspirante Se encuentra inscrito como cabeza de familia  en el proyecto " . $asp['Proyect']['codigo'] . "<br>";
                    }
                }
            }
            if ($cuenta1 > 0) {
                $can->Relative->recursive = -1;
                $relatives = $can->Relative->find('all', array('conditions' => array('Relative.nro_ident' => $pareja['Candidate']['nro_ident']), 'fields' => array('Relative.candidate_id')));
                foreach ($relatives as $rel) {
                    $padre = $can->find('first', array('conditions' => array('Candidate.id' => $rel['Relative']['candidate_id']), 'fields' => array('Candidate.1er_nombre', 'Candidate.1er_apellido', 'Candidate.nro_ident', 'Proyect.codigo')));
                    $resp.="El aspirante se encuentra como familiar de " . $padre['Candidate']['1er_nombre'] . " " . $padre['Candidate']['1er_apellido'] . ",Cedula: " . $padre['Candidate']['nro_ident'] . " ,en el proyecto: " . $padre['Proyect']['codigo'];
                    //var_dump($padre);
                }
            }
        }
        ?>
        <?php if ($resp <> ""): ?>

            <tr>
                <td style="color: #cb2c2c">DUPLICIDAD</td>
                <td colspan="3" style="color: #cb2c2c"><?php echo $resp ?></td>
                <td></td>
            </tr>
        <?php endif; ?>
    </tbody>
</table>
<br>
<br>





